package com.ylfstu.Homework;

public class Test {
    public static void main(String[] args) {
        Person[] person = new Person[3];
        person[0] = new Person("jack", 15, "学生");
        person[1] = new Person("jack", 30, "公司职员");
        person[2] = new Person("mary", 25, "教师");

        for (int i = 0; i < person.length; i++) {
            System.out.println(person[i].toString());
        }

        Person temp = null;
        for (int i = 0; i < person.length - 1; i++) {
            for (int j = 0; j < person.length - 1 - i; j++) {
                if (person[i].getAge() > person[i + 1].getAge()){
                    temp = person[i];
                    person[i] = person[i + 1];
                    person[i + 1] = temp;
                }
            }
        }
        for (int i = 0; i < person.length; i++) {
            System.out.println(person[i].toString());
        }
    }
}
